﻿using System;
using org.se.fs.presenter.Library;

namespace org.se.fs.presenter.View.Template
{
    public abstract class SubMenu<T> where T : new()
    {
        public event FormEvent.FormEventHandler OnError;
        public event FormEvent.FormEventHandler OnValidate;
        public event FormEvent.FormEventHandler OnAdd;
        public event FormEvent.FormEventHandler OnModify;
        public event FormEvent.FormEventHandler OnDelete;

        public UInt64 Uid { get; set; }
        public bool Active { get; set; }
        public DateTime DateCreated { get; set; }
        protected T Data { get; set; }

        protected void TriggerError(FormEvent e)
        {
            if (OnError != null)
                OnError(this, e);
        }

        protected void TriggerValidate(FormEvent e)
        {
            if (OnValidate != null)
                OnValidate(this, e);
        }

        protected void TriggerAdd(FormEvent e)
        {
            if (OnAdd != null)
                OnAdd(this, e);
        }

        protected void TriggerModify(FormEvent e)
        {
            if (OnModify != null)
                OnModify(this, e);
        }

        protected void TriggerDelete(FormEvent e)
        {
            if (OnDelete != null)
                OnDelete(this, e);
        }
    }

}
